# -*- coding: utf-8 -*-

"""
controller for index
"""

from framework.admincontroller import AdminController
from models.index import IndexModel
import tornado.web
import time

class IndexCtrl(AdminController):
    """index controller"""

    @tornado.web.authenticated
    def get(self):
        """index get"""
        m = IndexModel()
        datas = m.get_two_count()
        data = dict(today=dict(), yestoday=dict())
        if datas:
            data = dict(today=datas[0], yestoday=datas[1])
            data['today']['sync_time'] = time.strftime("%Y-%m-%d", time.localtime(data['today']['sync_time']))
        self.render("index.html", v=data['today'], yday=data['yestoday'])
        return
